import time
from config import base_dir
from utils.log import MyLogger

# 生成当前时间戳
nowTime = time.strftime("%Y{}%m{}%d{}_%H{}%M{}%S{}".format('年', '月', '日', '时', '分', '秒'), time.localtime())
print("当前时间：{}".format(nowTime))


# 生成路径_保存图片
def save_img(driver,log,error):
    save_img_path = base_dir + '\\img\\' + nowTime + '_' + error + '.png'
    try:
        print("保存图片路径：{}".format(save_img_path))
        driver.get_screenshot_as_file(save_img_path)
        log.info("错误信息处截图成功，详情请查看{}".format(save_img_path))
    except Exception as e:
        log.error("错误信息处截图失败")
        raise e


if __name__ == '__main__':
    save_img('类型错误')
